import React, { useEffect } from 'react'
import { RouteObject } from 'react-router/dist/lib/context'
import { useLocation, useRoutes } from 'react-router-dom'

interface IProps {
	routes: RouteObject[]
}

const Routes: React.FC<IProps> = (props) => {
	const location = useLocation()
	useEffect(() => {
		if (location.pathname === '/login') {
			window.localStorage.removeItem('graduation_yzh_token')
		}
	})
	return useRoutes(props.routes)
}

export default Routes